package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderStatisticsVO;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {




    /**
     * 根据订单号查询订单
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    /**
     * 插入新的订单
     * @param orders
     */
    void insert(Orders orders);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from orders where id=#{id}")
    Orders getById(Long id);

    /**
     * 分页查询
     * @param ordersPageQueryDTO
     * @return
     */
    Page<Orders> page(OrdersPageQueryDTO ordersPageQueryDTO);


    @Select("select count(id) from orders where status=#{status}")
    Integer countStatus(Integer status);

    /**
     * 根据订单状态查询超时时间
     * @param status
     * @param orderTime
     * @return
     */
    @Select("select * from orders where  status=#{status} and order_time=#{orderTime}")
    List<Orders> getBysStatusAndOrderTime(Integer status,LocalDateTime orderTime);

    /**
     * 动态查询营业额
     * @param map
     * @return
     */
    Double getBySumMap(Map map);

    /**
     * 订单数据统计
     * @param map
     * @return
     */
    Integer countByMap(Map map);

    /**
     * 某段实践内的销量前十彩票
     * @param begin
     * @param end
     * @return
     */
    List<GoodsSalesDTO> getSalesTop(LocalDateTime begin,LocalDateTime end);
}
